package com.campus.commons.utils;

import com.campus.app.mapper.Select;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@Data
/**
 * 分页条件类； 减少方法传入的参数
 */
@NoArgsConstructor
public class MyPage <T>{
    @NotNull(message = "page不能为null")
    @Min(value = 1,message = "当前页不能小于1")
    private Integer page=1;
    @NotNull(message = "不能为null")
    @Min(value = 1,message = "页大小不能小于1")
    private Integer limit=10;

    @NotNull(groups = Select.class)
    @Valid
    private T data;

    public MyPage(@NotNull @Min(value = 1, message = "当前页不能小于1") Integer current, @NotNull @Min(value = 1, message = "页大小不能小于1") Integer limit) {
        this.page = current;
        this.limit = limit;
    }
}